package com.ksy.common.dialog;

import android.content.Context;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;

/**
 * Created by Ksy.
 */

public class CenterDialog extends BaseDialog {
    public CenterDialog(@NonNull Context context) {
        super(context);
    }

    public CenterDialog(@NonNull Context context, int styleId) {
        super(context, styleId);
    }

    @Override
    public void show() {
        super.show();
        Window window = getWindow();
        if (window == null) {
            return;
        }
        WindowManager.LayoutParams lp = window.getAttributes();
        window.setGravity(Gravity.CENTER);
        lp.width = android.view.ViewGroup.LayoutParams.MATCH_PARENT;
        lp.height = android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
        window.setAttributes(lp);
    }
}
